/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.lis.model.newmodel;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Record;
import java.util.List;

/**
 *
 * @author cxhd
 */
@SuppressWarnings("serial")
public class LisReferencevalue extends Model<LisReferencevalue>{
     public static final LisReferencevalue lisReferencevaluedao=new LisReferencevalue();
     public void deleteLisRef(String testid){
         Db.use("mysql").update("delete from lis_referencevalue where TESTID=?",testid);
     }
     public void saveLisRef(String TESTID,String REFAGE,String MREFLO0,String MREFHI0,String FREFLO0,String FREFHI0,String SAMPLETYPE,String Decimalplace){
         set("PK", getPk())
                 .set("TESTID", TESTID)
                 .set("SAMPLETYPE",SAMPLETYPE )
                 .set("REFAGE",REFAGE )
                 .set("MREFLO0", MREFLO0)
                 .set("MREFHI0", MREFHI0)
                 .set("FREFLO0", FREFLO0)
                 .set("FREFHI0", FREFHI0)
                 .set("Decimalplace", Decimalplace)
                 .save();
                 
     }
     public void updateLisRef(String PK,String REFAGE,String MREFLO0,String MREFHI0,String FREFLO0,String FREFHI0,String SAMPLETYPE,String Decimalplace){
         findById(PK)
                
                 .set("REFAGE",REFAGE )
                 .set("MREFLO0", MREFLO0)
                 .set("MREFHI0", MREFHI0)
                 .set("FREFLO0", FREFLO0)
                 .set("FREFHI0", FREFHI0)
                  .set("SAMPLETYPE",SAMPLETYPE )
                 .set("Decimalplace", Decimalplace)
                 .update();
     }
     public String getPk(){
           List<Record> list=Db.use("mysql").find("select * from lis_referencevalue limit 0,10");
        String  value = "1";
        if(list.size()>0){
        value = (Integer.parseInt(Db.use("mysql").findFirst("SELECT MAX(PK) as id from lis_referencevalue ").get("id") + "") + 1) + "";
        }
      return value;
    }
}
